/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Funcionario;

import Medicamentos.Medicamento;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.Session;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import util.HibernateUtil;

/**
 *
 * @author Lucas
 */
public class FuncionarioDAO {
    
    private Session sessao;
    private Transaction transacao;
    
    public void salvar(Funcionario funcionario){
        
        sessao = HibernateUtil.getSessionFactory().openSession();
        transacao = sessao.beginTransaction();
        sessao.save(funcionario);
        transacao.commit();
        sessao.close();
        
    }
    
        
    
    

    public void salvar(Medicamento medicamento) {
        throw new UnsupportedOperationException("Not yet implemented");
    }
    
     public List<Funcionario> pesquisaNomeiLike(String nome){
        sessao = HibernateUtil.getSessionFactory().openSession();
        transacao = sessao.beginTransaction();
        List<Funcionario> funcionarios = (List<Funcionario>) sessao.createCriteria(Funcionario.class).
                add(Restrictions.ilike("nome", nome, MatchMode.ANYWHERE)).list();
        sessao.close();
        return funcionarios;
        
        
  
    
    
   
    
    
     }}
